<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改采购单')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-purchase-edit" th:object="${jtPurchaseOrder}">
        <h4 class="form-header h4">采购单信息</h4>
        <input name="purchaseId" th:field="*{purchaseId}" type="hidden">
        <input name="removeItemIds" type="hidden">
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label is-required">[[#{warehouse}]]：</label>
                <div class="col-sm-8">
                    <span th:text="*{warehouseName}"></span>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{supplier}]]：</label>
                <div class="col-sm-8">
                    <span th:text="*{supplierName}"></span>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label is-required">[[#{purchaseOrderNumber}]]：</label>
                <div class="col-sm-8">
                    <span th:text="*{orderNo}"></span>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{attributes}]]：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('jt_product_attributes')}">
                        <input type="radio" th:id="${'attributes_' + dict.dictCode}" name="attributes" th:value="${dict.dictValue}" th:field="*{attributes}">
                        <label th:for="${'attributes_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{logisticsCompany}]]：</label>
                <div class="col-sm-8">
                    <input name="logisticsCompany" th:field="*{logisticsCompany}" class="form-control" type="text" readonly>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{logisticsOrderNumber}]]：</label>
                <div class="col-sm-8">
                    <input name="logisticsNumber" th:field="*{logisticsNumber}" class="form-control" type="text" readonly>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{purchaser}]]：</label>
                <div class="col-sm-8">
                    <span th:text="*{purchaser}"></span>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{purchaseDate}]]：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="purchaseDate" th:value="${#dates.format(jtPurchaseOrder.purchaseDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{expectedDateOfArrival}]]：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="expectedArrivalDate" th:value="${#dates.format(jtPurchaseOrder.expectedArrivalDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{purchaseStatus}]]：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('jt_purchase_status')}">
                        <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
                        <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{receiver}]]：</label>
                <div class="col-sm-8">
                    <span th:text="*{receiver}"></span>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{phoneNumber}]]：</label>
                <div class="col-sm-8">
                    <span th:text="*{phoneNumber}"></span>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{address}]]：</label>
                <div class="col-sm-8">
                    <span th:text="*{country}"></span>
                    <span th:text="*{province}"></span>
                    <span th:text="*{city}"></span>
                    <span th:text="*{district}"></span>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{detailedAddress}]]：</label>
                <div class="col-sm-8">
                    <input name="fullAddress" th:field="*{fullAddress}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{remark}]]：</label>
                <div class="col-sm-8">
                    <input name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <h4 class="form-header h4" th:text="#{purchaseOrderDetails}">采购单明细信息</h4>
        <div class="row">
            <div class="col-sm-12">
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
    var prefix = ctx + "business/purchase";
    $("#form-purchase-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-purchase-edit').serialize());
        }
    }

    $("input[name='purchaseDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='expectedArrivalDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $(function() {
        var options = {
            data: [[${jtPurchaseOrder.jtPurchaseOrderItemList}]],
            pagination: false,
            search:true,
            showSearch:true,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            sidePagination: "client",
            columns: [{
                checkbox: true
            },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                        var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                        return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'productName',
                    align: 'center',
                    title: i18n('productName'),
                    formatter: function(value, row, index) {
                        return value;
                    }
                },
                {
                    field: 'productCode',
                    align: 'center',
                    title: i18n('sku'),
                    formatter: function(value, row, index) {
                        return value;
                    }
                },
                {
                    field: 'styleNo',
                    align: 'center',
                    title: i18n('spu'),
                    formatter: function(value, row, index) {

                        return value;
                    }
                },
                {
                    field: 'unitPrice',
                    align: 'center',
                    title: i18n('purchaseUnitPrice'),
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='number' name='jtPurchaseOrderItemList[%s].unitPrice' value='%s' readonly>", index, value);
                        return html;
                    }
                },
                {
                    field: 'qty',
                    align: 'center',
                    title: i18n('purchaseQuantity'),
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='number' name='jtPurchaseOrderItemList[%s].qty' value='%s' readonly>", index, value);
                        return html;
                    }
                },
                {
                    field: 'amount',
                    align: 'center',
                    title: i18n('purchaseAmount'),
                    formatter: function(value, row, index) {
                        return value;
                    }
                }]
        };
        $.table.init(options);
    });
</script>


<script th:inline="javascript">
    var ROOT = [[${#servletContext.contextPath}]];
    var LANG_COUNTRY = [[${#locale.language+'_'+#locale.country}]];

    //初始化i18n
    $.i18n.properties({
        path: ROOT + '/i18n/',//这里表示访问路径
        name: 'messages',//文件名开头
        language: LANG_COUNTRY,//文件名语言 例如en_US
        mode: 'map'//默认值
    });

    //i18n函数
    function i18n(msgKey) {
        try {
            return $.i18n.prop(msgKey);
        } catch (e) {
            return msgKey;
        }
    }
</script>
</body>
</html>